<?php
namespace app\applet\controller\alipay;
use app\applet\controller\Controller;
use hema\alipay\Driver;
use think\facade\View;
/**
 * 开发成员管理
 */
class Member extends Controller
{
    /**
     * 列表
     */
    public function index()
    {
		$alipay = new Driver($this->applet_id);
        $list = $alipay->openAppMembersQuery();
		return View::fetch('index', compact('list'));	
    }
    
    /**
     * 添加
     */
    public function add()
    {
        if ($this->request->isPost()) {
            $data = $this->postData('data');
            $alipay = new Driver($this->applet_id);
    		if(!$alipay->openAppMembersCreate($data['logon_id'],$data['role'])){
    			return $this->renderError($alipay->getError());
    		}
    		return $this->renderSuccess('添加成功',url('alipay.member/index'));
        }
        return redirect(url('alipay.member/index'));
    }
    
    /**
     * 删除
     */
    public function delete($id,$role)
    {
    	$alipay = new Driver($this->applet_id);
    	if(!$alipay->openAppMembersDelete($id,$role)){
			return $this->renderError($alipay->getError());
		}
		return $this->renderSuccess('删除成功');
    }
}